import gtk
import unittest

def window(widget=None):
    'return gtk.Window. terminate gtk.main when it is closed.'
    window = gtk.Window()
    window.connect('delete_event', gtk.main_quit)
    if widget:
        window.add(widget)
    window.show_all()
    return window

def image(icon_name, pixel_size):
    'return gtk.Image. given icon name and pixel size.'
    assert isinstance(icon_name, str)
    assert isinstance(pixel_size, int) and pixel_size>0
    image = gtk.Image()
    image.set_from_icon_name(icon_name, gtk.ICON_SIZE_DIALOG)
    image.set_pixel_size(pixel_size)
    return image

class _test(unittest.TestCase):
    def test_image(self):
        box = gtk.HBox(False, 10)
        for name in ['computer', 'user-home', 'user-trash', 'network-workgroup']:
            box.pack_start(image(name, 64))
        box2 = gtk.HBox(False, 10)
        for name in ['nautilus', 'accessories-text-editor', 'java', 'web-browser']:
            box2.pack_start(image(name, 32), False)
        vbox = gtk.VBox(False, 10)
        vbox.pack_start(box)
        vbox.pack_start(box2)
        window(vbox)
        gtk.main()